<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MAVLink Packaging - QGroundControl GCS</title>
<meta name="generator" content="DokuWiki"/>
<meta name="robots" content="index,follow"/>
<meta name="date" content="2012-03-01T08:37:34+0100"/>
<meta name="keywords" content="mavlink,packaging"/>
<link rel="search" type="application/opensearchdescription+xml" href="/lib/exe/opensearch.php" title="QGroundControl GCS"/>
<link rel="start" href="/"/>
<link rel="contents" href="/mavlink/packaging?do=index" title="Sitemap"/>
<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/feed.php"/>
<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="/feed.php?mode=list&amp;ns=mavlink"/>
<link rel="alternate" type="text/html" title="Plain HTML" href="/_export/xhtml/mavlink/packaging"/>
<link rel="alternate" type="text/plain" title="Wiki Markup" href="/_export/raw/mavlink/packaging"/>
<link rel="canonical" href="http://qgroundcontrol.org/mavlink/packaging"/>
<link rel="stylesheet" type="text/css" href="/lib/exe/css.php?t=mnml-blog&amp;tseed=1378908877"/>
<script type="text/javascript">/*<![CDATA[*/var NS='mavlink';var JSINFO = {"id":"mavlink:packaging","namespace":"mavlink"};
/*!]]>*/</script>
<script type="text/javascript" charset="utf-8" src="/lib/exe/js.php?tseed=1378908877"></script>

<link rel="shortcut icon" href="/lib/tpl/mnml-blog/images/favicon.ico" />
<script type="text/javascript" charset="utf-8" src="/lib/tpl/mnml-blog/user/user.js"></script>
<!--[if lt IE 7]><style type="text/css">img { behavior: url(/lib/tpl/mnml-blog/js/iepngfix/iepngfix.htc); }</style><![endif]-->
</head>

<body>
<div id="pagewrap">

    <!-- start header -->
    <div id="tmpl_header">
        <a href="/" name="dokuwiki__top" id="dokuwiki__top" accesskey="h"><img src="/lib/tpl/mnml-blog/user/logo.png" id="tmpl_header_logo_img" alt=""/></a>

       <div id="tmpl_header_nav">
<ul>
<li class="level1"><div class="li"> <a href="/start" class="wikilink1" title="start">Home</a></div>
</li>
<li class="level1"><div class="li"> <a href="/videos" class="wikilink1" title="videos">Videos</a></div>
</li>
<li class="level1"><div class="li"> <a href="/users/start" class="wikilink1" title="users:start">User&#039;s Guide</a></div>
</li>
<li class="level1"><div class="li"> <a href="/dev/start" class="wikilink1" title="dev:start">Developer&#039;s Guide</a></div>
</li>
<li class="level1"><div class="li"> <a href="/mavlink/start" class="wikilink1" title="mavlink:start">MAVLink</a></div>
</li>
<li class="level1"><div class="li"> <a href="/downloads" class="wikilink1" title="downloads">Downloads</a></div>
</li>
</ul>
            <div class="clearer"></div>
        </div>
        <div class="clearer"></div>
    </div>
    <!-- end header -->


    <!-- start main content area -->
    <div class="dokuwiki">
        
        <!-- start left col -->
        <div id="content">
            <div class="page">
                <!-- TOC START -->
<div id="dw__toc">
<h3 class="toggle">Table of Contents</h3>
<div>

<ul class="toc">
<li class="level1"><div class="li"><a href="#mavlink_packaging">MAVLink Packaging</a></div>
<ul class="toc">
<li class="level2"><div class="li"><a href="#message_definitions">Message Definitions</a></div></li>
<li class="level2"><div class="li"><a href="#pymavlink_generation">PyMAVLink Generation</a></div></li>
<li class="level2"><div class="li"><a href="#packaging_mavlink_releases">Packaging MAVLink Releases</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="#windows">Windows</a></div></li>
<li class="level3"><div class="li"><a href="#linux">Linux</a></div></li>
<li class="level3"><div class="li"><a href="#cross-compiling_on_linux_for_windows">Cross-compiling on Linux for Windows</a></div></li>
</ul></li>
</ul></li>
</ul>
</div>
</div>
<!-- TOC END -->
<div class="clearer"></div>

<!-- start rendered page content -->

<h1 class="sectionedit1" id="mavlink_packaging">MAVLink Packaging</h1>
<div class="level1">

<p>
<em>This page is intended for MAVLink developers only. If you just want to use the common message set, head to <a href="/mavlink/installation" class="wikilink1" title="mavlink:installation">Downloading / Installing MAVLink</a>, if you want to generate your own messages / your own dialect, head to <a href="/mavlink/generator" class="wikilink1" title="mavlink:generator">MAVLink Generator (C/C++, Python)</a>.</em>
</p>

</div>

<h2 class="sectionedit2" id="message_definitions">Message Definitions</h2>
<div class="level2">

<p>
All mavlink messages are generated off of the definitions under the message_definitions of the mavlink git repository root directory.
</p>

</div>

<h2 class="sectionedit3" id="pymavlink_generation">PyMAVLink Generation</h2>
<div class="level2">

<p>
Pymavlink is used to generate the C source code from the message definitions. This is the portion of the cmake file that automates this build process. CMake is used here to manage file dependencies and automate package generation as shown later.
</p>
<pre class="code cmake"><span class="co1"># mavlink generation</span>
<a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:macro"><span class="kw1">macro</span></a><span class="sy0">(</span>generateMavlink version definitions<span class="sy0">)</span>
    <a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:foreach"><span class="kw1">foreach</span></a><span class="sy0">(</span>definition <span class="re0">${definitions}</span><span class="sy0">)</span>
        <a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set"><span class="kw1">set</span></a><span class="sy0">(</span>targetName <span class="re0">${definition}</span>-v<span class="re0">${version}</span><span class="sy0">)</span>
        <a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set"><span class="kw1">set</span></a><span class="sy0">(</span>definitionAbsPath <span class="re0">${CMAKE_SOURCE_DIR}</span>/message_definitions/v<span class="re0">${version}</span>/<span class="re0">${definition}</span><span class="sy0">)</span>
        <a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:message"><span class="kw1">message</span></a><span class="sy0">(</span><span class="kw3">STATUS</span> <span class="st0">&quot;processing: <span class="es1">${definitionAbsPath}</span>&quot;</span><span class="sy0">)</span>
        <a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_custom_command"><span class="kw1">add_custom_command</span></a><span class="sy0">(</span> 
            <span class="kw3">OUTPUT</span> <span class="re0">${targetName}</span>-stamp
            <span class="kw3">COMMAND</span> <span class="re0">${PYTHON_EXECUTABLE}</span> <span class="re0">${mavgen}</span> --lang=C --wire-protocol=<span class="re0">${version}</span>
                --output=include/v<span class="re0">${version}</span> <span class="re0">${definitionAbsPath}</span>
            <span class="kw3">COMMAND</span> touch <span class="re0">${targetName}</span>-stamp
            <span class="kw3">DEPENDS</span> <span class="re0">${definitionAbsPath}</span> <span class="re0">${mavgen}</span>
            <span class="sy0">)</span>
        <a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_custom_target"><span class="kw1">add_custom_target</span></a><span class="sy0">(</span><span class="re0">${targetName}</span> ALL <span class="kw3">DEPENDS</span> <span class="re0">${targetName}</span>-stamp<span class="sy0">)</span>
    <a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endforeach"><span class="kw1">endforeach</span></a><span class="sy0">()</span>
<a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endmacro"><span class="kw1">endmacro</span></a><span class="sy0">()</span>
&nbsp;
<span class="co1"># build</span>
<a href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set"><span class="kw1">set</span></a><span class="sy0">(</span>mavgen <span class="re0">${CMAKE_CURRENT_SOURCE_DIR}</span>/pymavlink/generator/mavgen.py<span class="sy0">)</span></pre>

</div>

<h2 class="sectionedit4" id="packaging_mavlink_releases">Packaging MAVLink Releases</h2>
<div class="level2">

</div>

<h3 class="sectionedit5" id="windows">Windows</h3>
<div class="level3">
<ol>
<li class="level1"><div class="li"> Download cmake version 2.8 or later:<a href="http://www.cmake.org/cmake/resources/software.html" class="urlextern" title="http://www.cmake.org/cmake/resources/software.html"  rel="nofollow">http://www.cmake.org/cmake/resources/software.html</a></div>
</li>
<li class="level1"><div class="li"> Download and setup git on windows: <a href="http://www.sparkfun.com/tutorials/165" class="urlextern" title="http://www.sparkfun.com/tutorials/165"  rel="nofollow">http://www.sparkfun.com/tutorials/165</a> (Great Sparkfun tutorial on this.)</div>
</li>
<li class="level1"><div class="li"> Using Tortoise git, clone MAVLink.</div>
</li>
<li class="level1"><div class="li"> <pre class="code">git clone git://github.com/mavlink/mavlink.git -b pymavlink_merge </pre>
</div>
</li>
<li class="level1"><div class="li"> Use cmake gui, click configure, then click build.</div>
</li>
<li class="level1"><div class="li"> Now navigate to the cmake build directory and type cpack. A nullsoft installer will be produced.</div>
</li>
</ol>

</div>

<h3 class="sectionedit6" id="linux">Linux</h3>
<div class="level3">

</div>

<h4 id="install_cmake_and_download_mavlink">Install CMake and Download MAVLink</h4>
<div class="level4">
<pre class="code bash"><span class="kw2">sudo</span> <span class="kw2">apt-get install</span> cmake
<span class="kw2">mkdir</span> <span class="re5">-P</span> ~<span class="sy0">/</span>home<span class="sy0">/</span>Projects <span class="sy0">&amp;&amp;</span> <span class="kw3">cd</span> ~<span class="sy0">/</span>home<span class="sy0">/</span>Projects
<span class="kw2">git clone</span> git:<span class="sy0">//</span>github.com<span class="sy0">/</span>mavlink<span class="sy0">/</span>mavlink.git <span class="re5">-b</span> pymavlink_merge
<span class="kw3">cd</span> mavlink
<span class="kw2">mkdir</span> <span class="re5">-P</span> build
<span class="kw3">cd</span> build <span class="sy0">&amp;&amp;</span> cmake ..</pre>

</div>

<h4 id="compile_mavlink">Compile MAVLink</h4>
<div class="level4">
<pre class="code bash"><span class="kw3">cd</span> ~<span class="sy0">/</span>src<span class="sy0">/</span>Projects<span class="sy0">/</span>mavlink
<span class="kw2">mkdir</span> <span class="re5">-P</span> build
<span class="kw3">cd</span> build <span class="sy0">&amp;&amp;</span> cmake ..</pre>

</div>

<h4 id="create_a_linux_installer">Create a linux installer</h4>
<div class="level4">

<p>
If you are running Mac/ or a non-debian linux distribution this will create a self-extracting tarball package.
If you are running debian/ubunut it will create a debian installer that you can use to install mavlink on your system.
</p>
<pre class="code bash"><span class="kw3">cd</span> ~<span class="sy0">/</span>src<span class="sy0">/</span>Projects<span class="sy0">/</span>mavlink<span class="sy0">/</span>build-mingw <span class="sy0">&amp;&amp;</span> cpack</pre>

</div>

<h3 class="sectionedit7" id="cross-compiling_on_linux_for_windows">Cross-compiling on Linux for Windows</h3>
<div class="level3">

</div>

<h4 id="install_mingw_cross_env">Install mingw cross env</h4>
<div class="level4">

<p>
This will take around 10 hours to complete so do it overnight. You can type make library for a specific library but this ends up being more work.
</p>
<pre class="code bash"><span class="kw2">sudo</span> <span class="kw2">apt-get install</span> mercurial
<span class="kw2">mkdir</span> <span class="re5">-P</span> ~<span class="sy0">/</span>home<span class="sy0">/</span>Projects <span class="sy0">&amp;&amp;</span> <span class="kw3">cd</span> ~<span class="sy0">/</span>home<span class="sy0">/</span>Projects
http:<span class="sy0">//</span>mingw-cross-env.nongnu.org<span class="sy0">/</span>
hg clone http:<span class="sy0">//</span>hg.savannah.nongnu.org<span class="sy0">/</span>hgweb<span class="sy0">/</span>mingw-cross-env
<span class="kw3">cd</span> mingw-cross-env <span class="sy0">&amp;&amp;</span> <span class="kw2">make</span> <span class="kw2">install</span></pre>

</div>

<h4 id="run_ranlib_over_all_libs">Run ranlib over all libs</h4>
<div class="level4">

<p>
Some libraries may fail to link correctly. To prevent this rerun ranlib over all the static libraries.
</p>
<pre class="code bash"><span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> $<span class="br0">&#40;</span><span class="kw2">find</span> .<span class="sy0">/</span>usr<span class="sy0">/</span>i686-pc-mingw32<span class="sy0">/</span>lib <span class="re5">-regex</span> <span class="st0">&quot;.+\.a&quot;</span><span class="br0">&#41;</span>
<span class="kw1">do</span>
    <span class="kw3">echo</span> fixing <span class="re1">$file</span>
   .<span class="sy0">/</span>user<span class="sy0">/</span>bin<span class="sy0">/</span>i686-pc-ming32-ranlib <span class="re1">$file</span>
<span class="kw1">done</span></pre>

</div>

<h4 id="setup_path_for_cmake-mingw">Setup path for cmake-mingw</h4>
<div class="level4">

<p>
In the file ~/.profile you should create an alias for cmake-mingw
</p>
<pre class="code bash"><span class="kw3">alias</span> cmake-mingw=cmake -DCMAKE_TOOLCHAIN_FILE=~<span class="sy0">/</span>home<span class="sy0">/</span>Projects<span class="sy0">/</span>mingw-cross-env<span class="sy0">/</span>usr<span class="sy0">/</span>i686-pc-mingw32<span class="sy0">/</span>share<span class="sy0">/</span>cmake<span class="sy0">/</span>mingw-cross-env-conf.cmake</pre>

</div>

<h4 id="download_and_compile_the_code">Download and compile the code</h4>
<div class="level4">
<pre class="code bash"><span class="kw2">mkdir</span> <span class="re5">-P</span> ~<span class="sy0">/</span>home<span class="sy0">/</span>Projects <span class="sy0">&amp;&amp;</span> <span class="kw3">cd</span> ~<span class="sy0">/</span>home<span class="sy0">/</span>Projects
<span class="kw2">git clone</span> git:<span class="sy0">//</span>github.com<span class="sy0">/</span>mavlink<span class="sy0">/</span>mavlink.git <span class="re5">-b</span> pymavlink_merge
<span class="kw3">cd</span> mavlink
<span class="kw2">mkdir</span> <span class="re5">-P</span> build-mingw
<span class="kw3">cd</span> build-mingw <span class="sy0">&amp;&amp;</span> cmake-mingw ..</pre>

</div>

<h4 id="create_a_windows_installer">Create a windows installer</h4>
<div class="level4">

<p>
This step will create a nullsoft installer that you can use to install mavlink on your system.
</p>
<pre class="code bash"><span class="kw3">cd</span> ~<span class="sy0">/</span>src<span class="sy0">/</span>Projects<span class="sy0">/</span>mavlink<span class="sy0">/</span>build-mingw <span class="sy0">&amp;&amp;</span> cpack</pre>

</div>

<!-- end rendered page content -->
<div class="clearer"></div>


            </div>
        </div>
        <!-- end left col -->
        
        <!-- start right col -->
        <div id="tmpl_sidebar">
            
            <div class="sidebarnav">

<h1 class="sectionedit1" id="overview">Overview</h1>
<div class="level1">
<ul>
<li class="level1"><div class="li"> <a href="/start" class="wikilink1" title="start">Home</a></div>
</li>
<li class="level1"><div class="li"> <a href="/videos" class="wikilink1" title="videos">Videos</a></div>
</li>
<li class="level1"><div class="li"> <a href="/screenshots" class="wikilink1" title="screenshots">Screenshots</a></div>
</li>
<li class="level1"><div class="li"> <a href="/bugreporting" class="wikilink1" title="bugreporting">Bug Reporting</a></div>
</li>
<li class="level1"><div class="li"> <a href="/downloads" class="wikilink1" title="downloads">Downloads</a></div>
</li>
</ul>

</div>
<!-- EDIT1 SECTION "Overview" [1-136] -->
<h1 class="sectionedit2" id="mavlink">MAVLink</h1>
<div class="level1">
<ul>
<li class="level1"><div class="li"> <a href="/mavlink/start" class="wikilink1" title="mavlink:start">MAVLink Overview</a></div>
</li>
<li class="level1"><div class="li"> <a href="/mavlink/waypoint_protocol" class="wikilink1" title="mavlink:waypoint_protocol">Waypoint Protocol</a></div>
</li>
<li class="level1"><div class="li"> <a href="/mavlink/parameter_protocol" class="wikilink1" title="mavlink:parameter_protocol">Parameter Protocol</a></div>
</li>
<li class="level1"><div class="li"> <a href="/dev/mavlink_onboard_integration_tutorial" class="wikilink1" title="dev:mavlink_onboard_integration_tutorial">Onboard Integration</a></div>
</li>
<li class="level1"><div class="li"> <span class="curid"><a href="/dev/mavlink_linux_integration_tutorial" class="wikilink1" title="dev:mavlink_linux_integration_tutorial">Linux Integration</a></span></div>
</li>
</ul>

</div>
<!-- EDIT2 SECTION "MAVLink" [137-400] -->
<h1 class="sectionedit3" id="users">Users</h1>
<div class="level1">
<ul>
<li class="level1"><div class="li"> <a href="/users/start" class="wikilink1" title="users:start">User&#039;s Guide</a></div>
</li>
<li class="level1"><div class="li"> <a href="/about" class="wikilink1" title="about">About</a></div>
</li>
<li class="level1"><div class="li"> <a href="/credits" class="wikilink1" title="credits">Credits / Contact</a></div>
</li>
<li class="level1"><div class="li"> <a href="/license" class="wikilink1" title="license">License</a></div>
</li>
</ul>

</div>
<!-- EDIT3 SECTION "Users" [401-491] -->
<h1 class="sectionedit4" id="developers">Developers</h1>
<div class="level1">
<ul>
<li class="level1"><div class="li"> <a href="/dev/start" class="wikilink1" title="dev:start">Developer&#039;s Guide</a></div>
</li>
<li class="level1"><div class="li"> <a href="/dev/roadmap" class="wikilink1" title="dev:roadmap">Roadmap</a></div>
</li>
<li class="level1"><div class="li"> <a href="/dev/deployment" class="wikilink1" title="dev:deployment">Deployment</a></div>
</li>
<li class="level1"><div class="li"> <a href="/mavlink/start" class="wikilink1" title="mavlink:start">MAVLink</a></div>
</li>
<li class="level1"><div class="li"> <a href="/dev/coding_guidelines" class="wikilink1" title="dev:coding_guidelines">Coding Guidelines</a></div>
</li>
</ul>

</div>
<!-- EDIT4 SECTION "Developers" [492-] -->            </div>


            
            <div id="search" class="sidebarbox">
                <h5 class="hspec">Search</h5>
                <div class="level1"><form action="/start" accept-charset="utf-8" class="search" id="dw__search" method="get"><div class="no"><input type="hidden" name="do" value="search" /><input type="text" id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" /><input type="submit" value="Search" class="button" title="Search" /><div id="qsearch__out" class="ajax_qsearch JSpopup"></div></div></form>
                </div>
            </div>

            
            <div id="licenseinfo">
                <div class="license">Except where otherwise noted, content on this wiki is licensed under the following license: <a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license" class="urlextern">CC Attribution-Share Alike 3.0 Unported</a></div>
            </div>


            <div class="clearer"></div>
        </div>
        <!-- end right col -->
        <div class="clearer"></div>

        <div id="tmpl_footer">
            <div id="tmpl_footer_actlinksleft">
                [&#160;<a href="#dokuwiki__top"  class="action top" accesskey="t" rel="nofollow" title="Back to top [T]">Back to top</a>&#160;|&#160;<a href="/mavlink/packaging?do=index"  class="action index" accesskey="x" rel="nofollow" title="Sitemap [X]">Sitemap</a>&#160;]
            </div>
            <div id="tmpl_footer_actlinksright">
                [&#160;<a href="/mavlink/packaging?do=login&amp;sectok=ced0a41ffcda1565d306325d6f4db601"  class="action login" rel="nofollow" title="Login">Login</a>&#160;|&#160;<a href="/wiki/create_new_blogpost?do=login" rel="nofollow">New Post</a>&#160;]            </div>
            <div class="clearer"></div>
            <div id="tmpl_footer_metainfo">
                <a href="http://andreas-haerter.com/projects/dokuwiki-template-mnml-blog">mnml-blog</a> on <a href="http://www.dokuwiki.org/">DW</a> under the hood
            </div>
        </div>

    </div>
    <!-- end main content area -->
    <div class="clearer"></div>
    <img src="/lib/exe/indexer.php?id=mavlink%3Apackaging&amp;1431057431" width="2" height="1" alt="" />
</div>
</body>
</html>
